<?php
function signUp()
{
if(isset($_POST['username'], $_POST['password'], $_POST['passverify'], $_POST['email'], $_POST['buster']))// $_POST['username']!='')
{
  if(get_magic_quotes_gpc())
  {
    $_POST['username'] = stripslashes($_POST['username']);
    $_POST['password'] = stripslashes($_POST['password']);
    $_POST['passverify'] = stripslashes($_POST['passverif']);
    $_POST['email'] = stripslashes($_POST['email']);
  }
  if($_POST['password']==$_POST['passverify'])
  {
   if($_POST['buster']=='rtx6syz')
   {
    if(strlen($_POST['password'])>=6)
    {
    if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
      {
    $username = mysql_real_escape_string($_POST['username']);
      $password = mysql_real_escape_string(md5($_POST['password']));
      $email = mysql_real_escape_string($_POST['email']);
      $avatar = 'none';
      $dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
        if($dn==0)
        {
      $dn2 = mysql_num_rows(mysql_query('select id from users'));
          $id = $dn2+1;
      if(mysql_query('insert into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.date("d-m-Y h:i:s").'")'))
          {
      echo 'You may now log in';
      } else {
      echo 'There was a error signing in';
      }
      } else {
    echo 'This username is already taken';
    }
      } else {
    echo 'Email is not valid';
    }
    } else {
  echo 'Password must be more than 6 char';
  }
   } else {
   echo 'Captcha is wrong';
   }
  } else {
  echo 'Passwords do not match';
  }
} else {
echo 'All fields must be entered';
}

} //end function signUp()
//echo signUp();
?>